Skip to content

fix(all): return the property members of an entity in a stable order - #5331

Merged
MangelMaxime merged 1 commit into
mainfrom
fix/js-nondeterministic-codegen
Nov 24, 2026
Merged

MangelMaxime merged 1 commit into
mainfrom
fix/js-nondeterministic-codegen

Conversation

@MangelMaxime

Copy link
Copy Markdown
Member

Two compilations of the same project can give different output. For example, in tests/Js/Main the case test of a TypeScriptTaggedUnion was "width" in x in one compilation and "height" in x in the next.

FCS returns the property symbols from FSharpEntity.MembersFunctionsAndValues in an order that changes from one process to the next. PropertyCollector in InfoReader.fs keeps them in a ConcurrentDictionary keyed by the property name hash, and .NET randomizes string hashes per process.

Helpers.getMembersFunctionsAndValues now sorts the property symbols by declaration position. The other symbols keep their position. FsEnt and getAllInterfaceMembers use it, so all targets get the change.

There is no new test, because both orders give correct code. I compiled a small project 5 times for JavaScript and 5 times for Dart, and the outputs were identical.

@MangelMaxime
MangelMaxime marked this pull request as ready for review November 24, 2026 07:59
@MangelMaxime
MangelMaxime merged commit 6055a94 into main Nov 24, 2026
43 checks passed
@MangelMaxime
MangelMaxime deleted the fix/js-nondeterministic-codegen branch November 24, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant